<?php
$tm = $_GET['tm'];
$da = json_decode($tm,true);
$data=array('csm'=>"📍 我的人生进度瓶",'dfjs'=>"人生进度：",'df'=>null,'bq1' =>"年:",'bq2' =>"月:",'bq3'=>"周:",'bq4'=>"日:",'bq5'=>"此生:",'bq6'=>null,'pf1' =>1,'pf2'=>1,'pf3'=>1,'pf4'=>1,'pf5'=>1);
$nf = 2000;
switch($da[0]){
    case A: $nf=1990 ;break;
    case B: $nf=2000 ;break;
    case C: $nf=2010 ;break;
}
switch($da[1]){
    case A: $nf=$nf+0 ;break;
    case B: $nf=$nf+1 ;break;
    case C: $nf=$nf+2 ;break;
    case D: $nf=$nf+3 ;break;
    case E: $nf=$nf+4 ;break;
    case F: $nf=$nf+5 ;break;
    case G: $nf=$nf+6 ;break;
    case H: $nf=$nf+7 ;break;
    case I: $nf=$nf+8 ;break;
    case J: $nf=$nf+9 ;break;
}
$n=round(((date(m)-1)*30+date(d))/360,3)*100;
$y=round(((date(d)-1)*24+date(H))/720,3)*100;
$z=round(((date(w)-1)*24+date(H))/168,3)*100;
$r=round((date(H)*60+date(i))/1440,3)*100;
$cs=round(((2019-$nf)*365+date(m)*30+date(d))/26280,3)*100;
$data[bq5]=$data[bq5].$cs.'%';
$data[df]=$cs.'%';
$data[bq4]=$data[bq4].$r.'%';
$data[bq3]=$data[bq3].$z.'%';
$data[bq2]=$data[bq2].$y.'%';
$data[bq1]=$data[bq1].$n.'%';
if($n>=80){$data[pf1]=5;} elseif($n>=60){$data[pf1]=4;} elseif($n>=40){$data[pf1]=3;} elseif($n>=20){$data[pf1]=2;}else{$data[pf1]=1;}
if($y>=80){$data[pf2]=5;} elseif($y>=60){$data[pf2]=4;} elseif($y>=40){$data[pf2]=3;} elseif($y>=20){$data[pf2]=2;}else{$data[pf2]=1;}
if($z>=80){$data[pf3]=5;} elseif($z>=60){$data[pf3]=4;} elseif($z>=40){$data[pf3]=3;} elseif($z>=20){$data[pf3]=2;}else{$data[pf3]=1;}
if($r>=80){$data[pf4]=5;} elseif($r>=60){$data[pf4]=4;} elseif($r>=40){$data[pf4]=3;} elseif($r>=20){$data[pf4]=2;}else{$data[pf4]=1;}
if($cs>=80){$data[pf5]=5;} elseif($cs>=60){$data[pf5]=4;} elseif($cs>=40){$data[pf5]=3;} elseif($cs>=20){$data[pf5]=2;}else{$data[pf5]=1;}
echo json_encode($data,JSON_UNESCAPED_UNICODE);
$conn = new mysqli('127.0.0.1', '3h74cu729i222', 'gm666946','3h74cu729i222');
$conn ->set_charset("utf8");
$sql = "SELECT * FROM sjtj WHERE num = 0";
$res=$conn->query($sql);
$data=$res->fetch_all();
$sccs=$data[0][5]+1;
$sql = "UPDATE sjtj SET xpzcscs = '$sccs' WHERE num = 0";
$res=$conn->query($sql);
$conn->close();
?>